<script type="text/javascript" src="/static/js/vue2.5.1.js"></script>
<script src="/static/js/axios.min.js"></script>
<script type="text/javascript" src="__STATIC__/admin_page/lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="__STATIC__/admin_page/lib/layer/2.4/layer.js"></script>
<div id="app">
    <form action="">
        拒绝步骤:<select name="public-choice" v-model="refuse_step">
        <option :value="item.value" v-for="item in options">{{item.label}}</option>
    </select>
    </form>
    请输入拒绝原因:
    <ul>
        <li v-for='(list,index) in lists'>
            <input v-model="list.value" placeholder="请输入拒绝原因"/>
            <button v-on:click='lists.splice(index, 1)'>删除</button>
        </li>
    </ul>
    <button @click='addNewList'>添加拒绝原因</button>
    <button @click='ExamineService'>提交</button>
</div>
<script>

    var vm = new Vue({
        el: '#app',
        data: {
            newAddText: '',
            service_id: "{$service_id}",
            lists: [
                {value: ''},
            ],
            options: [
                {
                    value: '2',
                    label: '步骤二(基本信息)'
                }, {
                    value: '3',
                    label: '步骤三(证明信息)'
                }],
            refuse_step: 4
        },
        created() {
            this.refuse_step = this.options[0].value;
        },
        methods: {
            addNewList: function () {
                this.lists.push({
                    value: this.newAddText
                })
                this.newAddText = ''
            },
            ExamineService: function () {
                console.log(this.service_id)
                console.log(this.lists)
                if (this.lists[0].value.length > 1) {
                    axios.post('/admin/Service/ExamineService',
                        {
                            service_id: this.service_id,
                            service_info_status: 2,
                            request_type: 'h5',
                            error_message: this.lists,
                            refuse_step: this.refuse_step
                        }
                    ).then(response => {
                        if (response.data.status == 200) {
                            this.lists = {value: ''};
                            this.refuse_step = '';
                            layer.close()
                        } else {
                            layer.alert(response.data.msg)
                        }
                    })
                } else {
                    layer.alert('请填写拒绝原因!')
                }

            }
        }
    })
</script>